<?php
namespace PsiFramework\Classes\Util\Database\DatabaseInterface;

use \PsiFramework\Classes\Util\Database\SqlQuery;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * The Database is used to connect to the database
 *
 * @package Util.Database.Interface
 */
interface IDatabase
{

    /**
     * Execute a query
     *
     * @param       string          $query          the SQL query
     * @return      SQLObject       response
     */
    public function execute(/*string*/ $query);

    /**
     * Execute a SqlQuery
     *
     * @param       SqlQuery        $query          the SQL query
     * @return      SQLObject       response
     */
    public function executeQuery(SqlQuery $query);

    /**
     * Starts a transaction
     */
    public function startTransaction();

    /**
     * Commit transaction
     */
    public function commit();

    /**
     * Rollback transaction
     */
    public function rollback();

    /**
     * Get the next result
     *
     * @param object     $result
     * @param bool        $object        return an object ?
     */
    public function getNextResult(/*object*/ $result, /*bool*/ $object=true);

    /**
     * Returns the current value of the specified sequence
     *
     * @param       string  $sequenceName   the sequence name
     * @return      int             the last id
     */
    public function getLastId(/*string*/ $sequenceName);

    /**
     * Returns the value in the good sql format
     *
     * @param       mixed   $value          the value
     * @param       bool    $quotes         display quotes
     * @return      mixed   the formatted value
     */
    public function getValue(/*mixed*/ $value, /*bool*/ $quotes);

    /**
     * Returns the boolean value from the sql format
     *
     * @param       mixed   $value          the value
     */
    public function getBooleanValue(/*mixed*/ $value);
}
